/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package persistencia;

import java.util.Iterator;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author pabloavila
 */
@Stateless
public class PermisosFacade extends AbstractFacade<Permisos> implements PermisosFacadeLocal, PermisosFacadeRemote {
    @PersistenceContext(unitName = "elTabique2-ejbPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }

    public PermisosFacade() {
        super(Permisos.class);
    }

    @Override
    public Object getPermisos(String string) {
        boolean encontrado = false;
        if (this.findAll() == null) return null;
        Iterator<Permisos> itr = this.findAll().iterator();
        while (itr.hasNext() && !encontrado) {
            Permisos u = itr.next();
            if (u.getPermiso().equals(string)){
                encontrado = true;
                return u;
            }
        }
        return null;
    }

}
